//
//  JXTitleButton.swift
//  01-weiboSwift
//
//  Created by TwistFate on 16/3/1.
//  Copyright © 2016年 TwistFate. All rights reserved.
//

import UIKit

class JXTitleButton: UIButton {

    init (title : String , imageName :String) {
        super.init(frame: CGRectZero)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setImage(UIImage(named: imageName + "_down"), forState: UIControlState.Normal)
        self.setImage(UIImage(named: imageName + "_up"), forState: UIControlState.Selected)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        self.sizeToFit()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.titleLabel?.frame.origin.x = 0
        self.imageView?.frame.origin.x = (self.titleLabel?.frame.width)!
    }
}
